package com.jiyun.controller;


import com.jiyun.pojo.Commodity;
import com.jiyun.pojo.Result;
import com.jiyun.service.ICommodityService;
import com.jiyun.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-12-17
 */
@RestController
@RequestMapping("/api/commodity")
public class CommodityController {

    @Autowired
    private ICommodityService commodityService;

    @PostMapping("commodityshow")
    public Result commodityshow(@RequestBody Commodity commodity){
        List<Commodity> list = commodityService.commodityshow(commodity);
        return Result.success(list);
    }

    @PostMapping("commodityshowlist")
    public Result commodityshowlist(Integer[] id){
        List<Commodity> list = commodityService.commodityshowlist(id);
        return Result.success(list);
    }

    @RequestMapping("/add")
    public R add(@RequestBody Commodity commodity){
        return commodityService.add(commodity);
    }

    @RequestMapping("/delete")
    public R delete(Integer id){
        return commodityService.delete(id);
    }

}
